package com.wzk.dwetl.utils

import com.wzk.dwetl.beans.AppLogBean
import org.apache.spark.sql.Row

object Row2AppLogBean {

  def row2AppLogBean(row: Row): AppLogBean = {
    try {
      AppLogBean(
        row.getAs[String]("account"),
        row.getAs[String]("appid"),
        row.getAs[String]("appversion"),
        row.getAs[String]("carrier"),
        row.getAs[String]("deviceid"),
        row.getAs[String]("devicetype"),
        row.getAs[String]("eventid"),
        row.getAs[String]("ip"),
        row.getAs[Double]("latitude"),
        row.getAs[Double]("longitude"),
        row.getAs[String]("nettype"),
        row.getAs[String]("osname"),
        row.getAs[String]("osversion"),
        row.getAs[Map[String, String]]("properties"),
        row.getAs[String]("releasechannel"),
        row.getAs[String]("resolution"),
        row.getAs[String]("sessionid"),
        row.getAs[Long]("timestamp")
      )
    } catch {
      case e: Exception =>{
        e.printStackTrace()
        null
      }
    }

  }

}
